/**
 * Created by yuzhou on 2020/3/9.
 */
//vue获取数据
$(document).ready(function () {

    var data = new Vue({
        el:'#whole_box',
        data:{
            imglist:[],
            getImgUrl:"/market/getAdvantage",
            moredata:[],
            three_box_txt_show:true,

            market_shopping_guide_txt:"",
            brand_presentation_txt:"",
            about_us_txt:"",
            dynamic_infor_txt:"",
            enterprise_introduce_txt:"",
            learn_more_txt:"",
            bottom_txt:"",
            about_txt:"",
            search_txt:"",

            i1:"/xj/image/index/i1.jpg",
            i2:"/xj/image/index/i2.jpg",
            i3:"/xj/image/index/i3.jpg",
            i4:"/xj/image/index/i4.jpg",

            one:"市场导购",
            two:"动态资讯",
            three:"联系我们",

            video_url:"",
            lanuage_type:"",

            video_url:"http://www.invcert.com/video/cn.mp4",

            video_cn:true,
            video_en:false

        },
        mounted:function(){
            var self = this;
            var lanuage_id = self.getQueryValue("type");
            if(lanuage_id == "en"){
                localStorage.setItem("language", "en");
            }
            //localStorage.setItem("language", "cn");
            if(localStorage.getItem("language")== null ||localStorage.getItem("language")== ""　){
                localStorage.setItem("language", "cn");
                self.changeToCn();
                self.three_box_txt_show = true;
            }else{
                self.lanuage_type = localStorage.getItem("language");
                if(self.lanuage_type == "cn"){
                    self.changeToCn();
                    self.video_cn = true;
                    self.video_en = false;
                    self.three_box_txt_show = true;
                }else{
                    self.changeToEn();
                    self.video_cn = false;
                    self.video_en = true;
                    self.three_box_txt_show = false;
                }
            }

            /*点击切换中英文*/
            $("#btnCE").click(function () {
                console.log("Ssss"+localStorage.getItem("language"));
                var img = document.getElementById("btnCE");
                if(localStorage.getItem("language")=="en")
                {
                    img.src = "/xj/image/English.png"
                    img.alt="en"
                    localStorage.setItem("language", "cn");
                    self.changeToCn();
                    self.three_box_txt_show = true;
                }
                else {
                    img.src = "/xj/image/chinese.png"
                    img.alt="cn";
                    localStorage.setItem("language", "en");
                    self.changeToEn();
                    self.three_box_txt_show = false;
                }

            });

            $.ajax({
                type:"GET",
                url:"/market/getWpConig",
                data: {
                    clientUrl:window.location.href.split("#")[0]
                },
                dataType:"json",
                success:function(res){
                    wx.config({
                        debug: false,
                        appId: res.appId, // 和获取Ticke的必须一样------必填，公众号的唯一标识
                        timestamp: res.timestamp, // 必填，生成签名的时间戳
                        nonceStr: res.nonceStr, // 必填，生成签名的随机串
                        signature: res.signature,// 必填，签名，见附录1
                        //需要分享的列表项:发送给朋友，分享到朋友圈，分享到QQ，分享到QQ空间
                        jsApiList: [
                            'onMenuShareAppMessage', 'onMenuShareTimeline',
                            'onMenuShareQQ', 'onMenuShareQZone'
                        ]
                    });

                    var share_config = {
                        "imgUrl": "http://www.xinjisx.com/img/logo.jpg",
                        "desc": "",
                        "title": "信基沙溪",
                        "link": "http://www.xinjisx.com/page/redirectHome",
                        "success": function () {
                            //分享成功后的回调函数
                            // alert('分享成功')
                        },
                        "cancel": function () {
                            //用户取消分享执行的回调函数
                            // alert('分享成功')
                        }
                    };

                    wx.ready(function () {
                        wx.onMenuShareAppMessage(share_config);//分享给好友
                        wx.onMenuShareTimeline(share_config);//分享到朋友圈
                    });
                }
            });





        },
        created: function(){
            this.getImg()              //定义方法编译完成后执行
        },
        methods: {
            getQueryValue:function (a) {
                var query = decodeURI(window.location.search.substring(1));
                var vars = query.split("&");
                for (var i = 0; i < vars.length; i++) {
                    var pair = vars[i].split("=");
                    if (pair[0] == a) { return pair[1]; }
                }
                return null;
            },

            getImg: function(){
                var that = this;
                that.$http({           //调用接口
                    method:'post',

                    url:this.getImgUrl  //this指data
                }).then(function(response){  //接口返回数据

                    that.moredata = response.data;
                    console.log(JSON.stringify(that.moredata)+"xxx");
                    for(var i = 0;i<response.data.length;i++){
                        //错误代码，不要使用数组下标实现
                        //that.imglist[i]  = "http://zlanjie.top:18080"+"/wx/"+(response.data[i].pic_url)+i;
                        that.imglist.push("https://www.xinjisx.com"+"/wx/lubo/"+(response.data[i].pic_url)) ;
                        // console.log(response.data[i].pic_url+"xx");
                        console.log(that.imglist[i]);
                    }
                    // that.imglist.push("http://zlanjie.top:18080"+"/wx/"+(response.data[1].pic_url)) ;
                },function(error){
                    console.log("请求出错");
                })
            },

            changeToCn:function () {
                var self = this;
                self.video_url = "http://www.invcert.com/video/cn.mp4";
                self.one = "市场导购";
                self.two = "动态资讯";
                self.three = "联系我们";
                self.search_txt = "搜索更多..";
                self.market_shopping_guide_txt = "市场导购";
                self.brand_presentation_txt = "品牌展示";
                self.about_us_txt = "关于我们";
                self.dynamic_infor_txt = "动态资讯";
                self.enterprise_introduce_txt = "企业介绍";
                self.learn_more_txt = "了解更多";
                self.bottom_txt = "COPYRIGHT @ 2019信基沙溪股份有限公司版权所有";
                self.i1 = "/xj/image/index/i1.jpg";
                self.i2 = "/xj/image/index/i2.jpg";
                self.i3 = "/xj/image/index/i3.jpg";
                self.i4 = "/xj/image/index/i4.jpg";
                self.video_url ="http://v.qq.com/iframe/player.html?vid=u3076l8jp1m";
                self.about_txt = "信基沙溪集团股份有限公司（股票代码：3603.HK）中国酒店用品会长单位，中国最大的酒店用品市场运营商之一; 17年商业运营经验，始终专注酒店用品专业市场运营开发，现已发展成为“中国酒店用品产业领军者”";
            },

            changeToEn:function () {
                var self = this;
                self.video_url = "http://www.invcert.com/video/en.mp4";
                self.one = "MarketShopping"+"\n"+"Guide";
                self.two = "Dynamic"+"\n"+"Information";
                self.three = "Contact Us";
                self.search_txt = "Search More..";
                self.market_shopping_guide_txt = "Market Shopping Guide";
                self.brand_presentation_txt = "Brand Presentation";
                self.about_us_txt = "About Us";
                self.dynamic_infor_txt = "Dynamic informotion";
                self.enterprise_introduce_txt = "Enterprise Introduction";
                self.learn_more_txt = "Learn more";
                self.bottom_txt = "@2019 Copyright by Xinji Shaxi Group CO.,LTD";
                self.i1 = "/xj/image/index/i1_en.png";
                self.i2 = "/xj/image/index/i2_en.png";
                self.i3 = "/xj/image/index/i3_en.png";
                self.i4 = "/xj/image/index/i4_en.png";
                self.video_url ="http://v.qq.com/iframe/player.html?vid=e3076mwq86c";
                self.about_txt =" Xinji Shaxi Group Co., Ltd. ( stock code: 3603.HK) is the constituent company of Xinji Shaxi Group. Xinji Shaxi is the president agency of China Hotel Supplies Association and one of the biggest professional operators of China hotel supplies market. With 17 years’ commercial operator experiences, Xinji Shaxi has been kept focusing on the development and operation of professional hotel supplies market, and now becomes the leader of China hotel supplies industry."

            },

            goSearch:function () {
                window.location.href="/page/redirectSearch";
            }


        },



    })




});
$(document).ready(function () {
    //英文切换
    var img = document.getElementById("btnCE");
    //中文
    if(img.alt == "cn"){

    }
    //英文
    else{

    }

    $("#marketgo").click(function () {
        window.location.href = "/page/redirectMarketopens";
    });
    $("#storego").click(function () {
        window.location.href = "/page/redirectStore";
    });
    $("#contractgo").click(function () {
        window.location.href = "/page/redirectAboutus?id=1";
    });
});



